Add input validation to Subject.set_color_depth - #382
Closed
snowplow-claude-review[bot] wants to merge 1 commit into
Closed
Conversation
…2fa691c78-snowplow-python-tracker-29728427289)
|
Thanks for your pull request. Is this your first contribution to a Snowplow open source project? Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). 📝 Please visit https://docs.snowplowanalytics.com/docs/contributing/contributor-license-agreement/ to learn more and sign. Once you've signed, please reply here (e.g. I signed it!) and we'll verify. Thanks. |
Matus Tomlein (matus-tomlein)
deleted the
loop/3a307af295a281a9ba70f6d2fa691c78-snowplow-python-tracker-29728427289
branch
July 20, 2026 08:45
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
🤖 Draft implementation — refinement loop (3a307af295a281a9ba70f6d2fa691c78)
Drafted automatically by the Snowplow refinement loop (refine → product review → implement → review) from a Notion refinement, and opened here for a human to finish.
What the loop did
Add input validation to
Subject.set_color_depthSubject.set_color_depth(depth)accepted any integer, including zero and negatives, which are nonsensical screen colour-depth values. The sibling settersset_screen_resolutionandset_viewportalready guard their inputs with the repo'sgreater_thancontract helper;set_color_depthwas missing the same guard.Changes
snowplow_tracker/subject.pygreater_than(depth, 0)as the first statement ofset_color_depth, raisingValueErrorfor zero and negative inputs. Reuses the existing import on line 19 — no new error-handling patterns introduced.:type depth:docstring annotation frominttoint,>0to match sibling setters.snowplow_tracker/test/unit/test_subject.pytest_set_color_depth_validationtoTestSubject, assertingValueErrorfordepth=0anddepth=-1, and no exception fordepth=24.Key decisions
greater_thancontract helper — consistent withset_screen_resolutionandset_viewport, no new patterns.set_color_depthonly; no other setters touched.cdfield is unchanged; only invalid values are now rejected at the SDK boundary.Review checklist
greater_than(depth, 0)is the first statement inset_color_depth, before any assignment.int,>0.test_set_color_depth_validationcovers0and-1(expectValueError) and24(expect no exception).